fix(webdav): register chi REPORT method in init to avoid race with settings#2712
Conversation
|
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
rhafer
left a comment
There was a problem hiding this comment.
The change itself looks good to me. Please just remove the changelog file from the PR.
Thanks for making the effort to look into this bug!
There was a problem hiding this comment.
Please remove this file. We don't use actively use the changelog files anymore. The commit message is good enough.
I think the changelog directory is still there by accident. I'll create a PR to remove that.
|
Removed the changelog file in 274c067. Thanks for the review! |
…ncurrent route setup
274c067 to
04b0402
Compare
|
Done, dropped the changelog file and rebased onto current main, so the PR is just the single service.go change now. Thanks for the review. |



Description
Move
chi.RegisterMethod("REPORT")fromwebdav.NewServiceinto a packageinit()so it runs before any service goroutine is started by the suture supervisor.Related Issue
Motivation and Context
chi.RegisterMethodmutates the package-globalmethodMapingithub.com/go-chi/chi/v5, which(*node).setEndpointiterates during route insertion. opencloud starts many services concurrently under suture, so callingRegisterMethodinsideNewServicecould race with another service'smux.Route(...)and trigger a "concurrent map iteration and map write" fatal (the stack in #2686). Doing it ininit()happens during package import, before any supervised goroutine starts.chi.RegisterMethodis idempotent so it stays safe.How Has This Been Tested?
go build ./...andgofmton the affected package pass.go test -race ./services/webdav/pkg/service/v0/...builds cleanly under the race detector.I do not have a deterministic local reproducer for the intermittent panic, but the race is visible in the chi source (a package-global map written by
RegisterMethodand iterated bysetEndpoint).Screenshots (if appropriate):
n/a
Types of changes
Checklist: